package org.vshe.improve.spring.prospring3.ch5;

import java.beans.PropertyEditorSupport;

import org.springframework.context.support.GenericXmlApplicationContext;

public class NamePropertyEditor extends PropertyEditorSupport{

	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		String names[] = text.split("\\s");
		super.setValue(new Name(names[0], names[1]));
	}
	
	public static void main(String args[]) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext("ch5/custom-property-editor-test.xml");
		context.registerShutdownHook();
		
		NameBean bean = context.getBean(NameBean.class);
		System.out.println("RESULT :" + bean);
	}
}
